﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using OrbitOne.Elmah.Logic;

namespace OrbitOne.Elmah.Tests
{
    [TestFixture]
    public class Tests
    {
        [Test]
        public void Test1()
        {
            var errorXml = @"<error errorId=""6df50aa4-15ce-45ff-a8ca-2c413182a541"" application=""SuppliersNet WebApp"" host=""mail.yamagata-europe.com"" type=""System.ServiceModel.FaultException`1[[System.ServiceModel.ExceptionDetail, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]"" message=""The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://tempuri.org/:reg. The InnerException message was 'There was an error deserializing the object of type Yamagata.Translations.WCFDomain.Registration. The maximum string content length quota (8192) has been exceeded while reading XML data. This quota may be increased by changing the MaxStringContentLength property on the XmlDictionaryReaderQuotas object used when creating the XML reader. Line 1, position 11783.'.  Please see InnerException for more details."" source=""mscorlib"" detail=""System.Web.HttpUnhandledException: Exception of type 'System.Web.HttpUnhandledException' was thrown. ---&gt; System.ServiceModel.FaultException`1[System.ServiceModel.ExceptionDetail]: The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://tempuri.org/:reg. The InnerException message was 'There was an error deserializing the object of type Yamagata.Translations.WCFDomain.Registration. The maximum string content length quota (8192) has been exceeded while reading XML data. This quota may be increased by changing the MaxStringContentLength property on the XmlDictionaryReaderQuotas object used when creating the XML reader. Line 1, position 11783.'.  Please see InnerException for more details. (Fault Detail is equal to An ExceptionDetail, likely created by IncludeExceptionDetailInFaults=true, whose value is:&#xA;System.ServiceModel.Dispatcher.NetDispatcherFaultException: The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://tempuri.org/:reg. The InnerException message was 'There was an error deserializing the object of type Yamagata.Translations.WCFDomain.Registration. The maximum string content length quota (8192) has been exceeded while reading XML data. This quota may be increased by changing the MaxStringContentLength property on the XmlDictionaryReaderQuotas object used when creating the XML reader. Line 1, position 11783.'.  Please see InnerException for more details. ----&gt; System.Runtime.Serialization.SerializationException: There was an error deserializing the object of type Yamagata.Translations.WCFDomain.Registration. The maximum string content length quota (8192) has been exceeded while reading XML data. This quota may be increased...).&#xD;&#xA;   --- End of inner exception stack trace ---&#xD;&#xA;   at System.Web.UI.Page.HandleError(Exception e)&#xD;&#xA;   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)&#xD;&#xA;   at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)&#xD;&#xA;   at System.Web.UI.Page.ProcessRequest()&#xD;&#xA;   at System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context)&#xD;&#xA;   at System.Web.UI.Page.ProcessRequest(HttpContext context)&#xD;&#xA;   at ASP.registrationform_registrationotherinfo_aspx.ProcessRequest(HttpContext context) in c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\339aec66\a5c6f8fb\App_Web_e-cfwjan.1.cs:line 0&#xD;&#xA;   at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()&#xD;&#xA;   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&amp; completedSynchronously)"" time=""2009-04-22T14:28:01.4185000+02:00"" statusCode=""500"" webHostHtmlMessage=""&lt;html&gt;&#xD;&#xA;    &lt;head&gt;&#xD;&#xA;        &lt;title&gt;The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://tempuri.org/:reg. The InnerException message was 'There was an error deserializing the object of type Yamagata.Translations.WCFDomain.Registration. The maximum string content length quota (8192) has been exceeded while reading XML data. This quota may be increased by changing the MaxStringContentLength property on the XmlDictionaryReaderQuotas object used when creating the XML reader. Line 1, position 11783.'. &amp;nbsp;Please see InnerException for more details.&lt;/title&gt;&#xD;&#xA;        &lt;style&gt;&#xD;&#xA;         body {font-family:&quot;Verdana&quot;;font-weight:normal;font-size: .7em;color:black;} &#xD;&#xA;         p {font-family:&quot;Verdana&quot;;font-weight:normal;color:black;margin-top: -5px}&#xD;&#xA;         b {font-family:&quot;Verdana&quot;;font-weight:bold;color:black;margin-top: -5px}&#xD;&#xA;         H1 { font-family:&quot;Verdana&quot;;font-weight:normal;font-size:18pt;color:red }&#xD;&#xA;         H2 { font-family:&quot;Verdana&quot;;font-weight:normal;font-size:14pt;color:maroon }&#xD;&#xA;         pre {font-family:&quot;Lucida Console&quot;;font-size: .9em}&#xD;&#xA;         .marker {font-weight: bold; color: black;text-decoration: none;}&#xD;&#xA;         .version {color: gray;}&#xD;&#xA;         .error {margin-bottom: 10px;}&#xD;&#xA;         .expandable { text-decoration:underline; font-weight:bold; color:navy; cursor:hand; }&#xD;&#xA;        &lt;/style&gt;&#xD;&#xA;    &lt;/head&gt;&#xD;&#xA;&#xD;&#xA;    &lt;body bgcolor=&quot;white&quot;&gt;&#xD;&#xA;&#xD;&#xA;            &lt;span&gt;&lt;H1&gt;Server Error in '/' Application.&lt;hr width=100% size=1 color=silver&gt;&lt;/H1&gt;&#xD;&#xA;&#xD;&#xA;            &lt;h2&gt; &lt;i&gt;The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://tempuri.org/:reg. The InnerException message was 'There was an error deserializing the object of type Yamagata.Translations.WCFDomain.Registration. The maximum string content length quota (8192) has been exceeded while reading XML data. This quota may be increased by changing the MaxStringContentLength property on the XmlDictionaryReaderQuotas object used when creating the XML reader. Line 1, position 11783.'. &amp;nbsp;Please see InnerException for more details.&lt;/i&gt; &lt;/h2&gt;&lt;/span&gt;&#xD;&#xA;&#xD;&#xA;            &lt;font face=&quot;Arial, Helvetica, Geneva, SunSans-Regular, sans-serif &quot;&gt;&#xD;&#xA;&#xD;&#xA;            &lt;b&gt; Description: &lt;/b&gt;An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.&#xD;&#xA;&#xD;&#xA;            &lt;br&gt;&lt;br&gt;&#xD;&#xA;&#xD;&#xA;            &lt;b&gt; Exception Details: &lt;/b&gt;System.ServiceModel.FaultException`1[[System.ServiceModel.ExceptionDetail, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]: The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://tempuri.org/:reg. The InnerException message was 'There was an error deserializing the object of type Yamagata.Translations.WCFDomain.Registration. The maximum string content length quota (8192) has been exceeded while reading XML data. This quota may be increased by changing the MaxStringContentLength property on the XmlDictionaryReaderQuotas object used when creating the XML reader. Line 1, position 11783.'. &amp;nbsp;Please see InnerException for more details.&lt;br&gt;&lt;br&gt;&#xD;&#xA;&#xD;&#xA;            &lt;b&gt;Source Error:&lt;/b&gt; &lt;br&gt;&lt;br&gt;&#xD;&#xA;&#xD;&#xA;            &lt;table width=100% bgcolor=&quot;#ffffcc&quot;&gt;&#xD;&#xA;               &lt;tr&gt;&#xD;&#xA;                  &lt;td&gt;&#xD;&#xA;                      &lt;code&gt;&#xD;&#xA;&#xD;&#xA;An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.&lt;/code&gt;&#xD;&#xA;&#xD;&#xA;                  &lt;/td&gt;&#xD;&#xA;               &lt;/tr&gt;&#xD;&#xA;            &lt;/table&gt;&#xD;&#xA;&#xD;&#xA;            &lt;br&gt;&#xD;&#xA;&#xD;&#xA;            &lt;b&gt;Stack Trace:&lt;/b&gt; &lt;br&gt;&lt;br&gt;&#xD;&#xA;&#xD;&#xA;            &lt;table width=100% bgcolor=&quot;#ffffcc&quot;&gt;&#xD;&#xA;               &lt;tr&gt;&#xD;&#xA;                  &lt;td&gt;&#xD;&#xA;                      &lt;code&gt;&lt;pre&gt;&#xD;&#xA;&#xD;&#xA;[FaultException`1: The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://tempuri.org/:reg. The InnerException message was 'There was an error deserializing the object of type Yamagata.Translations.WCFDomain.Registration. The maximum string content length quota (8192) has been exceeded while reading XML data. This quota may be increased by changing the MaxStringContentLength property on the XmlDictionaryReaderQuotas object used when creating the XML reader. Line 1, position 11783.'.  Please see InnerException for more details.]&#xD;&#xA;   System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) +2668969&#xD;&#xA;   System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData&amp;amp; msgData, Int32 type) +717&#xD;&#xA;   Yamagata.YPtrack.Extranet.Domain.TranslationsDomainService.IService.CreateOrUpdateRegistration(Registration reg) +0&#xD;&#xA;   Yamagata.YPtrack.Extranet.Domain.TranslationsDomainService.ServiceClient.CreateOrUpdateRegistration(Registration reg) +17&#xD;&#xA;   Yamagata.Translations.Web.RegistrationBasePage.PersistRegistration(Int32 statusId) +200&#xD;&#xA;   Yamagata.Translations.Web.RegistrationBasePage.FinalizeRegistration() +126&#xD;&#xA;   Yamagata.Translations.Web.RegistrationOtherInfo.SaveData() +105&#xD;&#xA;   Yamagata.Translations.Web.RegistrationOtherInfo.saveButton_Click(Object sender, EventArgs e) +32&#xD;&#xA;   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +105&#xD;&#xA;   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +107&#xD;&#xA;   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7&#xD;&#xA;   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11&#xD;&#xA;   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33&#xD;&#xA;   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1746&#xD;&#xA;&lt;/pre&gt;&lt;/code&gt;&#xD;&#xA;&#xD;&#xA;                  &lt;/td&gt;&#xD;&#xA;               &lt;/tr&gt;&#xD;&#xA;            &lt;/table&gt;&#xD;&#xA;&#xD;&#xA;            &lt;br&gt;&#xD;&#xA;&#xD;&#xA;    &lt;/body&gt;&#xD;&#xA;&lt;/html&gt;&#xD;&#xA;"">
  <serverVariables>
    <item name=""ALL_HTTP"">
      <value string=""HTTP_CACHE_CONTROL:no-cache&#xD;&#xA;HTTP_CONNECTION:Keep-Alive&#xD;&#xA;HTTP_CONTENT_LENGTH:612&#xD;&#xA;HTTP_CONTENT_TYPE:application/x-www-form-urlencoded&#xD;&#xA;HTTP_ACCEPT:image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-ms-application, application/vnd.ms-xpsdocument, application/xaml+xml, application/x-ms-xbap, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, application/x-silverlight, */*&#xD;&#xA;HTTP_ACCEPT_ENCODING:gzip, deflate&#xD;&#xA;HTTP_ACCEPT_LANGUAGE:en-us&#xD;&#xA;HTTP_COOKIE:ASP.NET_SessionId=d5yhd0u3phismx45nxfwa045; RegId=2735099e-3a5f-495d-b793-4784124c81e9&#xD;&#xA;HTTP_HOST:suppliersnet.yamagata-europe.com&#xD;&#xA;HTTP_REFERER:https://suppliersnet.yamagata-europe.com/RegistrationForm/RegistrationOtherinfo.aspx&#xD;&#xA;HTTP_USER_AGENT:Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 1.1.4322; .NET CLR 3.5.30729; .NET CLR 3.0.30618)&#xD;&#xA;HTTP_UA_CPU:x86&#xD;&#xA;"" />
    </item>
    <item name=""ALL_RAW"">
      <value string=""Cache-Control: no-cache&#xD;&#xA;Connection: Keep-Alive&#xD;&#xA;Content-Length: 612&#xD;&#xA;Content-Type: application/x-www-form-urlencoded&#xD;&#xA;Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-ms-application, application/vnd.ms-xpsdocument, application/xaml+xml, application/x-ms-xbap, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, application/x-silverlight, */*&#xD;&#xA;Accept-Encoding: gzip, deflate&#xD;&#xA;Accept-Language: en-us&#xD;&#xA;Cookie: ASP.NET_SessionId=d5yhd0u3phismx45nxfwa045; RegId=2735099e-3a5f-495d-b793-4784124c81e9&#xD;&#xA;Host: suppliersnet.yamagata-europe.com&#xD;&#xA;Referer: https://suppliersnet.yamagata-europe.com/RegistrationForm/RegistrationOtherinfo.aspx&#xD;&#xA;User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 1.1.4322; .NET CLR 3.5.30729; .NET CLR 3.0.30618)&#xD;&#xA;UA-CPU: x86&#xD;&#xA;"" />
    </item>
    <item name=""APPL_MD_PATH"">
      <value string=""/LM/W3SVC/530349987/Root"" />
    </item>
    <item name=""APPL_PHYSICAL_PATH"">
      <value string=""D:\Program Files\Orbit One\SuppliersNet WebApp\"" />
    </item>
    <item name=""AUTH_TYPE"">
      <value string="""" />
    </item>
    <item name=""AUTH_USER"">
      <value string="""" />
    </item>
    <item name=""AUTH_PASSWORD"">
      <value string="""" />
    </item>
    <item name=""LOGON_USER"">
      <value string="""" />
    </item>
    <item name=""REMOTE_USER"">
      <value string="""" />
    </item>
    <item name=""CERT_COOKIE"">
      <value string="""" />
    </item>
    <item name=""CERT_FLAGS"">
      <value string="""" />
    </item>
    <item name=""CERT_ISSUER"">
      <value string="""" />
    </item>
    <item name=""CERT_KEYSIZE"">
      <value string=""128"" />
    </item>
    <item name=""CERT_SECRETKEYSIZE"">
      <value string=""1024"" />
    </item>
    <item name=""CERT_SERIALNUMBER"">
      <value string="""" />
    </item>
    <item name=""CERT_SERVER_ISSUER"">
      <value string=""OU=Organization Validation CA, O=GlobalSign, CN=GlobalSign Organization Validation CA"" />
    </item>
    <item name=""CERT_SERVER_SUBJECT"">
      <value string=""C=BE, S=Oost-Vlaanderen, L=Gent, OU=Development, O=YAMAGATA EUROPE, CN=*.yamagata-europe.com"" />
    </item>
    <item name=""CERT_SUBJECT"">
      <value string="""" />
    </item>
    <item name=""CONTENT_LENGTH"">
      <value string=""612"" />
    </item>
    <item name=""CONTENT_TYPE"">
      <value string=""application/x-www-form-urlencoded"" />
    </item>
    <item name=""GATEWAY_INTERFACE"">
      <value string=""CGI/1.1"" />
    </item>
    <item name=""HTTPS"">
      <value string=""on"" />
    </item>
    <item name=""HTTPS_KEYSIZE"">
      <value string=""128"" />
    </item>
    <item name=""HTTPS_SECRETKEYSIZE"">
      <value string=""1024"" />
    </item>
    <item name=""HTTPS_SERVER_ISSUER"">
      <value string=""OU=Organization Validation CA, O=GlobalSign, CN=GlobalSign Organization Validation CA"" />
    </item>
    <item name=""HTTPS_SERVER_SUBJECT"">
      <value string=""C=BE, S=Oost-Vlaanderen, L=Gent, OU=Development, O=YAMAGATA EUROPE, CN=*.yamagata-europe.com"" />
    </item>
    <item name=""INSTANCE_ID"">
      <value string=""530349987"" />
    </item>
    <item name=""INSTANCE_META_PATH"">
      <value string=""/LM/W3SVC/530349987"" />
    </item>
    <item name=""LOCAL_ADDR"">
      <value string=""10.254.1.13"" />
    </item>
    <item name=""PATH_INFO"">
      <value string=""/RegistrationForm/RegistrationOtherinfo.aspx"" />
    </item>
    <item name=""PATH_TRANSLATED"">
      <value string=""D:\Program Files\Orbit One\SuppliersNet WebApp\RegistrationForm\RegistrationOtherinfo.aspx"" />
    </item>
    <item name=""QUERY_STRING"">
      <value string="""" />
    </item>
    <item name=""REMOTE_ADDR"">
      <value string=""76.114.153.175"" />
    </item>
    <item name=""REMOTE_HOST"">
      <value string=""76.114.153.175"" />
    </item>
    <item name=""REMOTE_PORT"">
      <value string=""49584"" />
    </item>
    <item name=""REQUEST_METHOD"">
      <value string=""POST"" />
    </item>
    <item name=""SCRIPT_NAME"">
      <value string=""/RegistrationForm/RegistrationOtherinfo.aspx"" />
    </item>
    <item name=""SERVER_NAME"">
      <value string=""suppliersnet.yamagata-europe.com"" />
    </item>
    <item name=""SERVER_PORT"">
      <value string=""443"" />
    </item>
    <item name=""SERVER_PORT_SECURE"">
      <value string=""1"" />
    </item>
    <item name=""SERVER_PROTOCOL"">
      <value string=""HTTP/1.1"" />
    </item>
    <item name=""SERVER_SOFTWARE"">
      <value string=""Microsoft-IIS/6.0"" />
    </item>
    <item name=""URL"">
      <value string=""/RegistrationForm/RegistrationOtherinfo.aspx"" />
    </item>
    <item name=""HTTP_CACHE_CONTROL"">
      <value string=""no-cache"" />
    </item>
    <item name=""HTTP_CONNECTION"">
      <value string=""Keep-Alive"" />
    </item>
    <item name=""HTTP_CONTENT_LENGTH"">
      <value string=""612"" />
    </item>
    <item name=""HTTP_CONTENT_TYPE"">
      <value string=""application/x-www-form-urlencoded"" />
    </item>
    <item name=""HTTP_ACCEPT"">
      <value string=""image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-ms-application, application/vnd.ms-xpsdocument, application/xaml+xml, application/x-ms-xbap, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, application/x-silverlight, */*"" />
    </item>
    <item name=""HTTP_ACCEPT_ENCODING"">
      <value string=""gzip, deflate"" />
    </item>
    <item name=""HTTP_ACCEPT_LANGUAGE"">
      <value string=""en-us"" />
    </item>
    <item name=""HTTP_COOKIE"">
      <value string=""ASP.NET_SessionId=d5yhd0u3phismx45nxfwa045; RegId=2735099e-3a5f-495d-b793-4784124c81e9"" />
    </item>
    <item name=""HTTP_HOST"">
      <value string=""suppliersnet.yamagata-europe.com"" />
    </item>
    <item name=""HTTP_REFERER"">
      <value string=""https://suppliersnet.yamagata-europe.com/RegistrationForm/RegistrationOtherinfo.aspx"" />
    </item>
    <item name=""HTTP_USER_AGENT"">
      <value string=""Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 1.1.4322; .NET CLR 3.5.30729; .NET CLR 3.0.30618)"" />
    </item>
    <item name=""HTTP_UA_CPU"">
      <value string=""x86"" />
    </item>
  </serverVariables>
  <form>
    <item name=""__EVENTTARGET"">
      <value string="""" />
    </item>
    <item name=""__EVENTARGUMENT"">
      <value string="""" />
    </item>
    <item name=""__VIEWSTATE"">
      <value string=""/wEPDwUKLTQ4NTc3NzAyNGRksNpTYm3WD47Lg4kD3pq1XlR2Ulc="" />
    </item>
    <item name=""ctl00$ContentFormPlaceholder$personalCommentTextBox"">
      <value string=""Our company also provides translation services in Azerbaijani&gt;English (US) at 0.11 Euros/word for no matches (Azerbaijani is not listed as one of the languages on your registration form). Furthermore, we offer audio transcription services not only in English, but in a number of other languages as well."" />
    </item>
    <item name=""ctl00$ContentFormPlaceholder$saveButton"">
      <value string=""Send"" />
    </item>
    <item name=""__EVENTVALIDATION"">
      <value string=""/wEWBAL1tbLrDgKX59fIAwK5oIRQAouxjqEJuV68JA7vx9PJZ4HKlDMUbUWnxR8="" />
    </item>
  </form>
  <cookies>
    <item name=""ASP.NET_SessionId"">
      <value string=""d5yhd0u3phismx45nxfwa045"" />
    </item>
    <item name=""RegId"">
      <value string=""2735099e-3a5f-495d-b793-4784124c81e9"" />
    </item>
  </cookies>
</error>
";
            var orbitOneElmahErrorService = new OrbitOneElmahErrorService();
            var result = (int)orbitOneElmahErrorService.SaveError(errorXml, new Guid("6df50aa4-15ce-45ff-a8ca-2c413182a541"));
            Console.WriteLine(result);
        }
    }
}
